//
//  PYDeleteAlert.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/8.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit

class PYDeleteAlert: SYBaseView {

    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor.white
        v.layer.cornerRadius = 5
        return v
    }()
    
    let back: UIButton = {
        let v: UIButton  = UIButton()
        v.backgroundColor = UIColor.clear
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
//        v.image = UIImage(named: "yuyue_success")
        v.layer.cornerRadius = 3
        return v
    }()
    
    let titleLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 18.autoFontSize()
        v.text = "确定删除吗？"
        return v
    }()
    
    let contentLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
//        v.text = "您的预约信息已提交，请等待商家与您联系或留意短信通知"
        v.numberOfLines = 0
        v.textAlignment = .center
        return v
    }()
    
    let cancel: UIButton = {
        let v: UIButton  = UIButton()
        v.setTitle("取消", for: .normal)
        v.setTitleColor(UIColor(hex: 0x367FF6), for: .normal)
        v.titleLabel?.font = 18.autoFontSize()
        
        return v
    }()
    
    let sure: UIButton = {
        let v: UIButton  = UIButton()
        v.setTitle("删除", for: .normal)
        v.setTitleColor(UIColor(hex: 0xF55035), for: .normal)
        v.titleLabel?.font = 18.autoFontSize()
        
        return v
    }()
    
    public var shuxianView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xE6E6E6)
        return v
    }()

    override func initViews() {
        
        
        sure.addTarget(self, action: #selector(sureAction), for: .touchUpInside)
        cancel.addTarget(self, action: #selector(backAction), for: .touchUpInside)
        back.addTarget(self, action: #selector(backAction), for: .touchUpInside)
        self.backgroundColor = UIColor(white: 0, alpha: 0.5)
        addSubview(back)
        addSubview(bgView)
//        bgView.addSubview(pic)
        bgView.addSubview(titleLb)
//        bgView.addSubview(contentLb)
        bgView.addSubview(sure)
        bgView.addSubview(cancel)
        bgView.addSubview(lineView)
        bgView.addSubview(shuxianView)
        back.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        bgView.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(280.0.autoWidth())
            make.height.equalTo(120.0.autoWidth())
        }
//        pic.snp.makeConstraints { (make) in
//            make.top.equalToSuperview().offset(19.0.autoWidth())
//            make.centerX.equalToSuperview()
//            make.width.height.equalTo(47.0.autoWidth())
//        }
        titleLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(27.5.autoWidth())
            make.centerX.equalToSuperview()
            make.height.equalTo(17.0.autoWidth())
        }
//        contentLb.snp.makeConstraints { (make) in
//            make.top.equalTo(titleLb.snp.bottom).offset(14.5.autoWidth())
//            make.centerX.equalToSuperview()
//            make.height.equalTo(31.0.autoWidth())
//            make.left.equalToSuperview().offset(37.5.autoWidth())
//            make.right.equalToSuperview().offset(-37.5.autoWidth())
//        }
        sure.snp.makeConstraints { (make) in
            make.top.equalTo(lineView.snp.bottom)
            make.left.equalTo(self.snp.centerX)
            make.right.equalToSuperview()
            make.height.equalTo(45.0.autoWidth())
        }
        cancel.snp.makeConstraints { (make) in
            make.top.equalTo(lineView.snp.bottom)
            make.right.equalTo(self.snp.centerX)
            make.left.equalToSuperview()
            make.height.equalTo(45.0.autoWidth())
        }
        lineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(75.autoWidth())
            make.left.right.equalToSuperview()
            make.height.equalTo(0.5.autoWidth())
        }
        shuxianView.snp.makeConstraints { (make) in
            make.top.equalTo(lineView)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview()
            make.width.equalTo(0.5.autoWidth())
        }
    }
    
    @objc func backAction() {
        self.isHidden = true
        self.clickedClosure?(0)
    }
    @objc func sureAction() {
        self.isHidden = true
        self.clickedClosure?(1)
    }
    
}
